package com.shortterm.imgserver.utils;

import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageOutputStream;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

/**
 * @program: edge-detection
 * @author: Jieyao Lu
 * @description:
 * @create: 2024/7/8 20:48
 **/
public class ImgUtil {

    static void byte2image(byte[] data,String path){
            if(data.length<3||path.equals("")) return;
            try{
                FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));
                imageOutput.write(data, 0, data.length);
                imageOutput.close();
                System.out.println("Make Picture success,Please find image in " + path);
            } catch(Exception ex) {
                System.out.println("Exception: " + ex);
                ex.printStackTrace();
            }
    }

}
